package com.ruoyi.bases.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bases.domain.JwInternshipBases;
import com.ruoyi.bases.service.IJwInternshipBasesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 校外实习基地情况Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/bases/bases")
public class JwInternshipBasesController extends BaseController
{
    @Autowired
    private IJwInternshipBasesService jwInternshipBasesService;

    /**
     * 查询校外实习基地情况列表
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwInternshipBases jwInternshipBases)
    {
        startPage();
        List<JwInternshipBases> list = jwInternshipBasesService.selectJwInternshipBasesList(jwInternshipBases);
        return getDataTable(list);
    }

    /**
     * 导出校外实习基地情况列表
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:export')")
    @Log(title = "校外实习基地情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwInternshipBases jwInternshipBases)
    {
        List<JwInternshipBases> list = jwInternshipBasesService.selectJwInternshipBasesList(jwInternshipBases);
        ExcelUtil<JwInternshipBases> util = new ExcelUtil<JwInternshipBases>(JwInternshipBases.class);
        util.exportExcel(response, list, "校外实习基地情况数据");
    }

    /**
     * 获取校外实习基地情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:query')")
    @GetMapping(value = "/{ibId}")
    public AjaxResult getInfo(@PathVariable("ibId") Long ibId)
    {
        return success(jwInternshipBasesService.selectJwInternshipBasesByIbId(ibId));
    }

    /**
     * 新增校外实习基地情况
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:add')")
    @Log(title = "校外实习基地情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwInternshipBases jwInternshipBases)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        jwInternshipBases.setDeptId(104L);
        jwInternshipBases.setUserId(user.getUserId());
        return toAjax(jwInternshipBasesService.insertJwInternshipBases(jwInternshipBases));
    }

    /**
     * 修改校外实习基地情况
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:edit')")
    @Log(title = "校外实习基地情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwInternshipBases jwInternshipBases)
    {
        return toAjax(jwInternshipBasesService.updateJwInternshipBases(jwInternshipBases));
    }

    /**
     * 删除校外实习基地情况
     */
    @PreAuthorize("@ss.hasPermi('bases:bases:remove')")
    @Log(title = "校外实习基地情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ibIds}")
    public AjaxResult remove(@PathVariable Long[] ibIds)
    {
        return toAjax(jwInternshipBasesService.deleteJwInternshipBasesByIbIds(ibIds));
    }
}
